<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
        <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<button class="btn btn-danger" id="d1">点我</button>
<script>
    $('#d1').click(function() {
        $.ajax({
            url: '',
            type: 'post',
            data: JSON.stringify({username: 'AK', age: 19}),  // 默认是urlencoded格式
            contentType: 'application/json',  // 指定编码格式
            success: function(data) {

            }
        })
    })
</script>
</body>
</html>